#include "Common.hpp"
#include <unistd.h>

int main()
{
    char buff[1024];
    SetNonBlock(0);
    while (true)
    {
        int n = ::read(0, buff, sizeof(buff) - 1);
        if (n > 0)
        {
            buff[n] = 0;
            std::cout << "echo# " << buff << std::endl;
        }
        else
        {
            if (errno == EWOULDBLOCK || errno == EAGAIN)
            {
                std::cout << "底层数据没有就绪" << std::endl;
                sleep(1);
                continue;
            }
            else if(errno == EINTR)
            {
                std::cout << "收到信号" << std::endl;
                continue;
            }
            else
            {
                std::cout << "读取出错" << std::endl;
                sleep(1);
                // break;
            }
        }
    }
    return 0;
}